/**
 * 2017年11月21日
 */
package com.alibaba.study.concurrent;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static java.lang.System.out;
/**
 * @author Alex
 *
 */
public class FutureDemo {
	static void sleep(int k){
		try{
			TimeUnit.SECONDS.sleep(k);
		}catch(Exception e){
			//ignore
		}
	}
	static ExecutorService es = Executors.newFixedThreadPool(10);
	public static void main(String[] args) throws Exception {
		CompletableFuture<String> cf = new CompletableFuture<>();
		es.submit(()->{
			sleep(3);
			cf.complete("hehe");
		});
		out.println("main is wating");
		
		out.println(cf.get());
		
		out.println("main end");
	}
}
